package org.biubiu0002.baiblog.core.api;

import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.biubiu0002.baiblog.core.service.ConversationService;
import org.biubiu0002.baiblog.im.api.ConversationApiService;
import org.biubiu0002.baiblog.im.dto.conversation.ConversationCardDto;
import org.biubiu0002.baiblog.im.dto.message.Message;

import javax.annotation.Resource;

/**
 * @Author: biubiu0002
 * @Date: 2022/11/21 17:29
 **/
@DubboService
public class ConversationApiServiceImpl implements ConversationApiService {

    @Resource
    private ConversationService conversationService;

    @Override
    public ConversationCardDto getConversationCard(String uid) {
        Preconditions.checkArgument(StringUtils.isNotBlank(uid),"用户uid不能为空");
        return conversationService.getConversationCard(uid);

    }

    @Override
    public void readUnreadMessage(String uid, String sessionId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(uid),"用户uid不能为空");
        Preconditions.checkArgument(StringUtils.isNotBlank(sessionId),"sessionId不能为空");
        conversationService.readUnreadMessage(uid,sessionId);

    }

    @Override
    public void updateLatestMessage(Message message) {
        conversationService.updateLatestMessage(message);
    }
}
